package P26;

/**
 * @Author DJ同学
 * @Date 2021/2/23 22:42
 * @Version 1.0
 * @Name 删除排序数组中的重复项
 * @Problem https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/
 */
public class Solution {
    public int removeDuplicates(int[] nums) {
        if(nums==null||nums.length==0)return 0;
        int cur=0;
        int pre=nums[cur];
        for(int i = 0;i<nums.length;i++){
            if(pre!=nums[i]){
                cur++;
                nums[cur]=nums[i];
                pre=nums[i];
            }
        }

        return cur+1;
    }
}
